<template>
  <div>
    <div>
        <el-form label-width="auto" label-position="left" :model="CompleteTaskVO" :rules="rules" ref="CompleteTaskVOForm">
            <el-row>
                <el-col>
                    <el-form-item label="审批人员:" prop="assignee">
                        <el-select style="float: left;width: 95%;" filterable v-model="CompleteTaskVO.assignee" placeholder="请选择审批人员" clearable>
                           <el-option-group
                             v-for="group in DepartmentGroupViewUserList"
                             :key="group.institutionsId"
                             :label="group.institutionsName">
                             <el-option
                               v-for="item in group.children"
                               :key="item.userId"
                               :label="item.realName"
                               :value="item.realName">
                             </el-option>
                           </el-option-group>
                         </el-select>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                  <el-col>
                      <el-form-item label="批注意见:" prop="notation">
                          <el-input type="textarea" style="float: left;width: 95%;"
                              :rows="4"
                              prefix-icon="el-icon-edit" v-model="CompleteTaskVO.notation"
                                    ></el-input>
                      </el-form-item>
                  </el-col>
            </el-row>
        </el-form>
        <span>
            <el-button @click="CancelReturn">取 消</el-button>
            <el-button type="primary" @click="CompleteTaskAndNoSpecifiedExecutorAssign">确 定</el-button>
        </span>
    </div>
  </div>
</template>

<script>
export default {
    name:"AuditPass",
    data(){
        return{
          CompleteTaskVO:{
            taskId:this.taskId,
            assignee:'',
            notation:'情况属实，同意！',
            type:"通过"
          },
          DepartmentGroupViewUserList:[],
          // 校验规则
          rules: {
              assignee:{required:true,message:'请输入审批人员',trigger:'blur'},
              notation:{required: true, message: '请输入批注意见', trigger: 'blur'}
          }
        }
    },
    props:['taskId'],
    mounted(){
      this.selectDepartmentGroupViewUserList();
    },
    methods:{
      //  按部门分组查询人员
      selectDepartmentGroupViewUserList(){
        this.getRequest("/account/BtAccountUser/select/DepartmentGroupViewUserList").then(resp => {
            if (resp) {
               this.DepartmentGroupViewUserList = resp.data;
            }
        });
      },
      // 跳转待办任务页面
      CancelReturn(){
        this.$router.replace('/officeWaitingDealWithTask')
      },
      // 审核通过请求
      CompleteTaskAndNoSpecifiedExecutorAssign(){
        this.$refs['CompleteTaskVOForm'].validate(valid => {
          if (valid) {
            this.putRequest("/activity/WaitingDealWithTask/update/CompleteTaskAndNoSpecifiedExecutorAssign",this.CompleteTaskVO).then(resp => {
                if (resp) {
                    this.CancelReturn();
                }
            });
          }
        })
      }
    }
  }
</script>

<style scoped>
  .el-form-item__label-wrap {
    margin-left: 0px !important;
  }
</style>
